/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sims.execution;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 *
 * @author BinhMV
 */
public class EncryptData {
    public String encryptData(String data) throws NoSuchAlgorithmException{
        byte[] str = data.getBytes();
        MessageDigest md = MessageDigest.getInstance("MD5");
        byte[] encryptStr = md.digest(str);
        StringBuilder result = new StringBuilder();
        for(int i=0;i<encryptStr.length;i++){
            result.append(Integer.toHexString(0xf8 & encryptStr[i]));
        }
        return result.toString();
    }
    
    public String checkNull(String data){
        if(data==null || data.length()==0){
            return "not empty !";
        }
        else {
            return null;
        }
    }
}
